﻿using AutoMapper;
using Pay.DTO;
using Pay.Data;
using Pay.IService;

namespace Pay.Service.AutoMapper {

	public class TopicProductMapper : IStartupDto {
		private IMapperConfigurationExpression _cfg;
		public TopicProductMapper(IMapperConfigurationExpression cfg) {
			_cfg = cfg;
		}
		public void Execute() {
			Create();
		}
		protected virtual void Create() {

			_cfg.CreateMap<TopicProduct, topic_product_dto>()
				.ForMember(dest => dest.id, src => src.MapFrom(c => c.Id))
				.ForMember(dest => dest.group_id, src => src.MapFrom(c => c.GroupId))
				.ForMember(dest => dest.product_id, src => src.MapFrom(c => c.ProductId))
				.ForMember(dest => dest.sort, src => src.MapFrom(c => c.Sort))
				.ForMember(dest => dest.product, src => src.MapFrom(c => c.Product));

			_cfg.CreateMap<topic_product_dto, TopicProduct>()
			   	.ForMember(dest => dest.Id, src => src.MapFrom(c => c.id))
			   	.ForMember(dest => dest.GroupId, src => src.MapFrom(c => c.group_id))
			   	.ForMember(dest => dest.ProductId, src => src.MapFrom(c => c.product_id))
			   	.ForMember(dest => dest.Sort, src => src.MapFrom(c => c.sort))
				.ForMember(dest => dest.Product, src => src.MapFrom(c => c.product));
		}
	}
}
